﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 解释器模式Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] romans = { "MCMXXVIII","", "MMMCMXCIX", "LXXX", "CDXIV", "DCCCI", "XCVIII", "MCMLXXVI", "XXXIX"};
            foreach (var roman in romans)
            {
                Context context = new Context() { Input = roman };

                List<Expression> list = new List<Expression>()
                {
                    new ThousandExpression(), new HundredExpression(), new TenExpression(), new OneExpression()
                };

                foreach (var expression in list)
                {
                    expression.Interpret(context);
                }

                Console.WriteLine("{0}={1}",roman, context.Output);
            }
            
            Console.ReadLine();
        }
    }
}
